fix: resilient default-company resolution on dashboard open#6
Merged
Conversation
Ledger Lab opened to a warning + no data when the resolved default company didn't exist — e.g. a stale user default (a leftover "LL E2E Probe" pointing at a deleted company) took precedence over the valid Global Default and made get_balances throw "Company X does not exist." Key decisions: - Backend `_resolve_company` no longer throws on a missing/stale default; it falls back to the first company the user can read (the Company picker only ever submits real companies, so this never masks a genuine bad selection). Only a company-less site still errors. - Frontend syncs the picker to the server-resolved company via `sync_company_field()`, so a stale client-side default is corrected to the company actually being shown (guarded against a reload loop). Files: ledger_lab/api/dashboard.py, ledger_lab/.../page/ledger_lab/ledger_lab.js Verified (agent-browser, ledger.localhost): page loads with picker=BWH, all boxes populated, equation "✓ Balanced", feed rows present, no warning. Notes for next iteration: issues #5 (transaction filters) and #3 (equation card UI) remain open. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4
Problem
Opening Ledger Lab showed a warning popup and no data whenever the resolved default company didn't exist. On this bench a stale user default (
Company = "LL E2E Probe", a leftover from an E2E run pointing at a company that no longer exists) took precedence over the valid Global DefaultBWH, soget_balancesthrewCompany LL E2E Probe does not exist.and the dashboard rendered blank.Fix
_resolve_company): a missing or stale default no longer throws. It falls back to the first company the user can read, so the page always opens with data. The Company picker only ever submits real companies, so this lenient fallback never masks a genuine bad selection. Only a truly company-less site still errors (with a clearer message).sync_company_field): the picker is synced to the server-resolved company afterrefresh(), so a stale client-side default is corrected to the company actually being shown. Guarded so it doesn't retrigger a reload.Verification (agent-browser,
ledger.localhost)LL E2E Probe)._resolve_company(None),_resolve_company("LL E2E Probe"), and_resolve_company("BWH")all returnBWH.🤖 Generated with Claude Code